using SerialPortCommunicationProject;
using SerialPortCommunicationProject.Tools;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.IO.Ports;
using System.Linq;
using System.Net;
using System.Net.Sockets;
using System.Threading.Tasks;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Threading;
using Tool;

namespace Tool
{

    //设备类
    public class Device: ViewModelBase
    {
        
        private string name = "";//设备名称
        private string commMode;//通信协议
        private ObservableCollection<Command> commands;//去重集合保存命令列表
        private string encoding;//设备用的指令编码

        private string portName="";
        private int baudRate;
        private Parity parity;
        private int dataBits;
        private StopBits stopBits;

        private bool isServer;
        private string ip="";
        private int port;

        public string Name {
            get => name; 
            set
            {
                name = value;
                RaisePropertyChanged("Name");
            }
        }
        public string CommMode
        { 
            get => commMode;
            set
            {
                commMode = value;
                RaisePropertyChanged("CommMode");
            }
        }
        public ObservableCollection<Command> Commands
        {
            get => commands;
            set
            {
                commands = value;
                RaisePropertyChanged("Commands");
            }
        }

        public string Encoding { 
            get => encoding;
            set
            {
                encoding = value;
                RaisePropertyChanged("Encoding");
            }
        }
        public string PortName
        {
            get => portName;
            set
            {
                portName = value;
                RaisePropertyChanged("PortName");
            }
        }
        public int BaudRate
        {
            get => baudRate;
            set
            {
                baudRate = value;
                RaisePropertyChanged("BaudRate");
            }
        }
        public Parity Parity
        {
            get => parity;
            set
            {
                parity = value;
                RaisePropertyChanged("Parity");
            }
        }
        public int DataBits
        {
            get => dataBits;
            set
            {
                dataBits = value;
                RaisePropertyChanged("DataBits");
            }
        }
        public StopBits StopBits
        {
            get => stopBits;
            set
            {
                stopBits = value;
                RaisePropertyChanged("StopBits");
            }
        }
        public bool IsServer
        {
            get => isServer;
            set
            {
                isServer = value;
                RaisePropertyChanged("IsServer");
            }
        }
        public string Ip
        {
            get => ip;
            set
            {
                ip = value;
                RaisePropertyChanged("Ip");
            }
        }
        public int Port
        {
            get => port;
            set
            {
                port = value;
                RaisePropertyChanged("Port");
            }
        }
    }
}
